package indi.zhifa.engine.core.excel.handler;


import indi.zhifa.engine.core.common.enums.service.IEnumMemoService;
import lombok.RequiredArgsConstructor;
import java.util.HashMap;
import java.util.Map;


@RequiredArgsConstructor
public class ExcelHandlers {
    Map<Class,IExcelCellHandler> handlerMap;
    private final IEnumMemoService mEnumMemoService;

    public void init( ){
        EnumCellHandler enumCellHandler = new EnumCellHandler(mEnumMemoService);

        handlerMap = new HashMap<Class,IExcelCellHandler>(10){{
            put(StringCellHandler.class,new StringCellHandler());
            put(IntegerCellHandler.class,new IntegerCellHandler());
            put(DoubleCellHandler.class,new DoubleCellHandler());
            put(FloatCellHandler.class,new FloatCellHandler());
            put(TimeCellHandler.class,new TimeCellHandler());
            put(BooleanCellHandler.class,new BooleanCellHandler());
            put(EnumCellHandler.class,enumCellHandler);
        }};
    }

    public IExcelCellHandler getHandler(Class pClass){
        return handlerMap.get(pClass);
    }

    public void addHandler(Class pClass, IExcelCellHandler pHandler){
        handlerMap.put(pClass,pHandler);
    }
}
